package com.woniuxy.charin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.charin.mapper.CouponsMapper;
import com.woniuxy.charin.model.entity.Coupons;
import com.woniuxy.charin.service.CouponsService;
import org.springframework.stereotype.Service;

/**
* @author 28196
* @description 针对表【coupons】的数据库操作Service实现
* @createDate 2024-12-23 21:27:49
*/
@Service
public class CouponsServiceImpl extends ServiceImpl<CouponsMapper, Coupons>
    implements CouponsService{
    @Override
    public Page<Coupons> findCoupons(int pageNum, int pageSize, String name, String status) {
        Page<Coupons> pages = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<Coupons> wrapper = Wrappers.lambdaQuery(Coupons.class)
                .like(StringUtils.isNotBlank(name), Coupons::getName, name)
                .eq(StringUtils.isNotBlank(status), Coupons::getStatus, status)
                .orderByDesc(Coupons::getCreatedTime);
        return page(pages, wrapper);
    }
}




